Where will the image be saved? [closed]

Posted by Dummy Derp on Programmers See other posts from Programmers or by Dummy Derp
Published on 2012-09-11T16:05:58Z Indexed on 2012/09/11 21:48 UTC
Read the original article Hit count: 223

Filed under:
|
|
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.File;

...

public void captureScreen(String fileName) throws Exception {

   Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
   Rectangle screenRectangle = new Rectangle(screenSize);
   Robot robot = new Robot();
   BufferedImage image = robot.createScreenCapture(screenRectangle);
   ImageIO.write(image, "png", new File(fileName));

}
...  

Going over this code I found on the internet. I got everything except the part where file is created.
In what format file name should be? Should it be C:/myFolder/myImage.png" or just myImage.png and where will it be saved?
Here is what docs say:
File

public File(String pathname)
Creates a new File instance by converting the given pathname string into an abstract pathname. If the given string is the empty string, then the result is the empty abstract pathname.
Parameters:
pathname - A pathname string
Throws:
NullPointerException - If the pathname argument is null

© Programmers or respective owner

Related posts about java

Related posts about file-storage